﻿using System;
using System.Web.Mvc;

namespace Realm.Web.Binders
{
    public abstract class BaseModelBinder
    {
        protected T GetFormValue<T>(ModelBindingContext bindingContext, string key)
        {
            var result = bindingContext.ValueProvider.GetValue(key);
            return result != null ? (T)Convert.ChangeType(result.AttemptedValue, typeof(T)) : default(T);
        }
    }
}